package com.jucai.pppeiyouclient.view.activity;

import android.Manifest;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.text.TextUtils;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import com.alibaba.sdk.android.oss.ClientException;
import com.alibaba.sdk.android.oss.ServiceException;
import com.alibaba.sdk.android.oss.callback.OSSCompletedCallback;
import com.alibaba.sdk.android.oss.model.PutObjectRequest;
import com.alibaba.sdk.android.oss.model.PutObjectResult;
import com.bumptech.glide.Glide;
import com.jph.takephoto.model.TImage;
import com.jph.takephoto.model.TResult;
import com.jucai.pppeiyouclient.MainActivity;
import com.jucai.pppeiyouclient.R;
import com.jucai.pppeiyouclient.base.BaseTakePhotoActivity;
import com.jucai.pppeiyouclient.base.PermissionListener;
import com.jucai.pppeiyouclient.comm.CommonData;
import com.jucai.pppeiyouclient.comm.CommonMethod;
import com.jucai.pppeiyouclient.comm.CommonRequestNetData;
import com.jucai.pppeiyouclient.utils.ActivityCollector;
import com.jucai.pppeiyouclient.utils.CompressPhoto;
import com.jucai.pppeiyouclient.utils.ImageHandleUtils;
import com.jucai.pppeiyouclient.utils.LogUtils;
import com.jucai.pppeiyouclient.utils.LoginUtils;
import com.jucai.pppeiyouclient.utils.OssUtils;
import com.jucai.pppeiyouclient.utils.SharedPreferencesUtil;
import com.jucai.pppeiyouclient.utils.ToastUtils;
import com.jucai.pppeiyouclient.view.dialog.IdCardExampleDialog;
import com.jucai.pppeiyouclient.view.popup.HeadUploadPopup;

import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

public class RegisterThirdStepActivity extends BaseTakePhotoActivity {
    private static final String TAG = "RegisterThirdStepActivity : ";

    private static final int TAKE_PHOTO = 2001;
    private static final int CHOOSE_IMAGE = 2002;
    private static final int CROP_IMAGE = 2003;


    private ImageView registerPosImg, registerNegImg, registerHandImg, topImg;
    private TextView registerDescView, registerSubmitVer, registerJump;
    private int type;

    private IdCardExampleDialog cardDialog;
    private HeadUploadPopup headUploadPopup;
    private File imageStore = new File(Environment.getExternalStorageDirectory(),
            CommonData.STORAGE_PICTURE_HEAD_FILE + System.currentTimeMillis() + ".jpg");

    private String objectFrontKey, objectReverseKey, objectHandKey;//正面，背面，手持
    private int photoType = 0;//0 正面 1背面 2手持

    private EditText nameEt;
    private EditText idCardNumberEt;
    private EditText addressEt;
    private String nameStr = "";
    private String idCardNumberStr = "";
    private String addressStr = "";
    private boolean isImageUploading = false;

    private TextView tvNotVerify;

    private int memberApplyStatus;
    private String memberApplyStatusText, iDcardInhand, iDcardFront, iDcardBack, realName, idCardNumber, realAddress, memberApplyVerifyDetails;


    @Override
    public boolean dispatchKeyEvent(KeyEvent event) {
        if (event.getKeyCode() == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_UP) {
            if (TextUtils.equals(SharedPreferencesUtil.getStringPreference(RegisterThirdStepActivity.this, "PREFERENCE", "password", ""), "for_main_not_pass")) {
                ActivityCollector.removeActivity(this);
            }
            return true;
        }
        return super.dispatchKeyEvent(event);
    }

    @Override
    protected void initView(Bundle savedInstanceState) {
        setContentView(R.layout.activity_register_third_step);

        ((TextView) findViewById(R.id.common_title_text)).setText("身份验证");
        registerJump = (TextView) findViewById(R.id.register_jump);
        registerPosImg = (ImageView) findViewById(R.id.register_pos_img);
        registerNegImg = (ImageView) findViewById(R.id.register_neg_img);
        topImg = (ImageView) findViewById(R.id.top_img);

        registerHandImg = (ImageView) findViewById(R.id.register_hand_img);
        registerDescView = (TextView) findViewById(R.id.register_desc_view);
        registerSubmitVer = (TextView) findViewById(R.id.register_submit_ver);
        tvNotVerify = (TextView) findViewById(R.id.tv_not_verify);

        nameEt = (EditText) findViewById(R.id.autoNym_nameEt);
        idCardNumberEt = (EditText) findViewById(R.id.autoNym_idCardNumberEt);
        addressEt = (EditText) findViewById(R.id.autoNym_addressEt);

    }

    @Override
    protected void initData() {
        cardDialog = new IdCardExampleDialog(RegisterThirdStepActivity.this);
        cardDialog.setHeight((int) (RegisterThirdStepActivity.this.getResources().getDisplayMetrics().heightPixels * 0.8));

        type = getIntent().getIntExtra("type", 0);


        if (type == 1) {
            ((TextView) findViewById(R.id.common_title_text)).setText("实名认证");
            registerJump.setVisibility(View.INVISIBLE);

            memberApplyStatus = getIntent().getIntExtra("status", 0);
            memberApplyStatusText = getIntent().getStringExtra("status_name");
            iDcardInhand = getIntent().getStringExtra("iDcardInhand");
            iDcardFront = getIntent().getStringExtra("iDcardFront");
            iDcardBack = getIntent().getStringExtra("iDcardBack");

            realName = getIntent().getStringExtra("realName");
            realAddress = getIntent().getStringExtra("realAddress");
            idCardNumber = getIntent().getStringExtra("idCardNumber");

            memberApplyVerifyDetails = getIntent().getStringExtra("memberApplyVerifyDetails");

            setData();

        } else if (type == 0) {
            findViewById(R.id.common_home_back).setVisibility(View.INVISIBLE);
        }else if(type == 2){
            registerJump.setVisibility(View.INVISIBLE);
        }
    }

    private void setData() {
        if (memberApplyStatus == -1) {
            tvNotVerify.setVisibility(View.VISIBLE);
            tvNotVerify.setText("原因：" + memberApplyVerifyDetails);
        }
        if (memberApplyStatus >= 0) {
            nameEt.setEnabled(false);
            idCardNumberEt.setEnabled(false);
            addressEt.setEnabled(false);

            registerHandImg.setEnabled(false);//手持
            registerPosImg.setEnabled(false);//正面
            registerNegImg.setEnabled(false);//反面

            registerSubmitVer.setText(memberApplyStatusText);
            registerSubmitVer.setEnabled(false);
            registerSubmitVer.setBackgroundResource(R.drawable.shape_round_corner_gray_4dp);

            if (!TextUtils.isEmpty(iDcardInhand)) {
                Glide.with(this).load(iDcardInhand).into(registerHandImg);
            }

            if (!TextUtils.isEmpty(iDcardFront)) {
                Glide.with(this).load(iDcardFront).into(registerPosImg);
            }

            if (!TextUtils.isEmpty(iDcardBack)) {
                Glide.with(this).load(iDcardBack).into(registerNegImg);
            }

        }

        topImg.setVisibility(View.GONE);

        nameEt.setText(realName);
        idCardNumberEt.setText(idCardNumber);
        addressEt.setText(realAddress);


    }

    @Override
    protected void loadNetData() {

    }

    public static void startRealName(Context context, int type) {
        Intent intent = new Intent(context, RegisterThirdStepActivity.class);
        intent.putExtra("type", type);
        context.startActivity(intent);
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (resultCode == RESULT_OK) {
            switch (requestCode) {
                case TAKE_PHOTO:
                    if (photoType == 0) {
                        showCropImage(data, registerPosImg);
                    } else if (photoType == 1) {
                        showCropImage(data, registerNegImg);
                    } else if (photoType == 2) {
                        showCropImage(data, registerHandImg);
                    }
                    break;
                default:
                    break;
            }
        }
    }

    @Override
    protected void setListener() {
        findViewById(R.id.common_back).setOnClickListener(this);
        findViewById(R.id.common_home_back).setOnClickListener(this);
        registerJump.setOnClickListener(this);
        registerPosImg.setOnClickListener(this);
        registerNegImg.setOnClickListener(this);
        registerHandImg.setOnClickListener(this);
        registerDescView.setOnClickListener(this);
        registerSubmitVer.setOnClickListener(this);
        cardDialog.setOnclickListener(this);
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.common_back:
                if (type == 1 || type == 2) {
                    ActivityCollector.removeActivity(this);
                } else {
                    if (TextUtils.equals(SharedPreferencesUtil.getStringPreference(RegisterThirdStepActivity.this, "PREFERENCE", "password", ""), "for_main_not_pass")) {
                        ActivityCollector.removeActivity(this);
                    }
                }
                break;

            case R.id.common_home_back:
                startActivity(new Intent(RegisterThirdStepActivity.this, MainActivity.class));
                ActivityCollector.removeActivity(this);
                break;

            case R.id.register_jump:
                if (TextUtils.equals(SharedPreferencesUtil.getStringPreference(RegisterThirdStepActivity.this, "PREFERENCE", "password", ""), "for_main_not_pass")) {
                    ActivityCollector.removeActivity(RegisterThirdStepActivity.this);
                    return;
                } else {
                    startActivity(new Intent(RegisterThirdStepActivity.this, MainActivity.class));
                    ActivityCollector.removeActivity(RegisterThirdStepActivity.this);
                    ActivityCollector.removeActivity(LoginActivity.activity);
                }
                /*
                HashMap<String, String> param = new HashMap<>();
                param.put("service", "Accompany_Login.go");
                param.put("member_phone", SharedPreferencesUtil.getStringPreference(RegisterThirdStepActivity.this,
                        "PREFERENCE", "phone", ""));
                param.put("password", SharedPreferencesUtil.getStringPreference(RegisterThirdStepActivity.this,
                        "PREFERENCE", "password", ""));

                CommonRequestNetData.getJsonObjectData(RegisterThirdStepActivity.this, param, true, new CommonRequestNetData.JsonObjectCallBack() {
                    @Override
                    public void parseJsonObject(JSONObject jsonObject) {
                        LogUtils.e(TAG + "jsObj = " + jsonObject.toString());
                        ToastUtils.showToast("登录成功");
                        try {
                            String token = jsonObject.getString("token");
                            String memberId = jsonObject.getString("member_id");
                            String rongyun_token = jsonObject.has("rongyun_token") ? jsonObject.getString("rongyun_token") : "";
                            LogUtils.e(TAG + "token = " + token + " , memberId = " + memberId + ",rongyun_token:" + rongyun_token);
                            CommonData.saveLoginData(RegisterThirdStepActivity.this, memberId,
                                    SharedPreferencesUtil.getStringPreference(RegisterThirdStepActivity.this, "PREFERENCE", "password", ""), token, rongyun_token);
                            startActivity(new Intent(RegisterThirdStepActivity.this, MainActivity.class));
                            ActivityCollector.removeActivity(RegisterThirdStepActivity.this);
                        } catch (JSONException e) {
                            e.printStackTrace();
                        }
                    }
                });
                */
                break;
            case R.id.register_pos_img:
                if (isImageUploading) {
                    ToastUtils.showToast("上传图片中，请稍后再试");
                    break;
                }
                photoType = 0;
                imgHandle(TAKE_PHOTO, 0, view);
                break;

            case R.id.register_neg_img:
                if (isImageUploading) {
                    ToastUtils.showToast("上传图片中，请稍后再试");
                    break;
                }
                photoType = 1;
                imgHandle(TAKE_PHOTO, 0, view);
                break;

            case R.id.register_hand_img:
                if (isImageUploading) {
                    ToastUtils.showToast("上传图片中，请稍后再试");
                    break;
                }
                photoType = 2;
                imgHandle(TAKE_PHOTO, 0, view);
                break;

            case R.id.register_desc_view:
                cardDialog.show();
                break;

            case R.id.register_submit_ver:
                if (isImageUploading) {
                    ToastUtils.showToast("上传图片中，请稍后再试");
                    break;
                }
                nameStr = nameEt.getText().toString().trim();
                idCardNumberStr = idCardNumberEt.getText().toString().trim();
                addressStr = addressEt.getText().toString().trim();
                if (TextUtils.isEmpty(objectFrontKey)) {
                    ToastUtils.showToast("请上传身份证正面");
                    break;
                }
                if (TextUtils.isEmpty(objectReverseKey)) {
                    ToastUtils.showToast("请上传身份证反面");
                    break;
                }
                if (TextUtils.isEmpty(objectHandKey)) {
                    ToastUtils.showToast("请上传手持身份证");
                    break;
                }

                if (TextUtils.isEmpty(nameStr)) {
                    ToastUtils.showToast("姓名不能为空");
                    break;
                }
                /*if (TextUtils.isEmpty(addressStr)) {
                    ToastUtils.showToast("联系地址不能为空");
                    break;
                }*/
                if (TextUtils.isEmpty(idCardNumberStr) || idCardNumberStr.length() != 18) {
                    ToastUtils.showToast("请输入18位身份证号码");
                    break;
                }

                HashMap<String, String> photoParam = new HashMap<>();
                photoParam.put("service", "Accompany_Apply.Apply");
                photoParam.put("IDcard_front", objectFrontKey);
                photoParam.put("IDcard_back", objectReverseKey);
                photoParam.put("IDcard_inhand", objectHandKey);
                photoParam.put("token", LoginUtils.getToken(RegisterThirdStepActivity.this));
                photoParam.put("member_id", LoginUtils.getMember_id(RegisterThirdStepActivity.this));
                photoParam.put("member_realname", nameStr);
                photoParam.put("member_IDcardno", idCardNumberStr);
                if (!TextUtils.isEmpty(addressStr)) {
                    photoParam.put("member_area_info", addressStr);
                }

                CommonRequestNetData.getJsonStringData(RegisterThirdStepActivity.this, photoParam, true, new CommonRequestNetData.JsonStringCallBack() {
                    @Override
                    public void parseJsonString(String str) {
                        LogUtils.e(TAG + "str = " + str);
                        startActivity(new Intent(RegisterThirdStepActivity.this, RegisterInfoReviewingActivity.class));
                        finish();
                    }
                });

                break;
            default:
                break;
        }
    }

    private void imgHandle(final int requestCode1, final int requestCode2, View view) {
        if (headUploadPopup == null) {
            headUploadPopup = new HeadUploadPopup(this, getWindow(), R.style.animBottomInBottomOut,
                    new View.OnClickListener() {
                        @Override
                        public void onClick(View view) {
                            headUploadPopup.dismiss();
                            switch (view.getId()) {
                                case R.id.upload_photo:


                                    if (Build.VERSION.SDK_INT >= 23) {
                                        RegisterThirdStepActivity.this.onRuntimePermissionRequest(new String[]{Manifest.permission.CAMERA, Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.READ_EXTERNAL_STORAGE},
                                                new PermissionListener() {
                                                    @Override
                                                    public void onGranted() {
                                                        imageStore = new File(Environment.getExternalStorageDirectory(),
                                                                CommonData.STORAGE_PICTURE_HEAD_FILE + System.currentTimeMillis() + ".jpg");
                                                        ImageHandleUtils.takePhoto(RegisterThirdStepActivity.this, imageStore, requestCode1);
                                                    }

                                                    @Override
                                                    public void onDenied(List<String> deniedPermissions) {
                                                        runOnUiThread(new Runnable() {
                                                            @Override
                                                            public void run() {
                                                                ToastUtils.showToast("调起摄像头失败！");
                                                            }
                                                        });
                                                    }
                                                });
                                    } else {
                                        imageStore = new File(Environment.getExternalStorageDirectory(),
                                                CommonData.STORAGE_PICTURE_HEAD_FILE + System.currentTimeMillis() + ".jpg");
                                        ImageHandleUtils.takePhoto(RegisterThirdStepActivity.this, imageStore, requestCode1);
                                    }
                                    break;
                                case R.id.upload_album:
                                    getTakePhoto().onPickMultiple(1);

//                                if (Build.VERSION.SDK_INT >= 23) {
//                                    //写SD卡权限申请
//                                    BaseActivity.onRuntimePermissionRequest(new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},
//                                            new PermissionListener() {
//                                                @Override
//                                                public void onGranted() {
//                                                    ImageHandleUtils.openAlum(RegisterThirdStepActivity.this, requestCode2);
//                                                }
//
//                                                @Override
//                                                public void onDenied(List<String> deniedPermissions) {
//                                                    for (String p : deniedPermissions) {
//                                                        Toast.makeText(ActivityCollector.getTopActivity(),
//                                                                p + "权限被拒绝", Toast.LENGTH_SHORT).show();
//                                                    }
//                                                }
//                                            });
//                                } else
//                                    ImageHandleUtils.openAlum(RegisterThirdStepActivity.this, requestCode2);
                                    break;

                                case R.id.upload_cancel:
                                    headUploadPopup.dismiss();
                                    break;
                                default:
                                    break;
                            }
                        }
                    });
        }
        headUploadPopup.showAtLocation(view, Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL, 0, 0);
        CommonMethod.setWindowAlpha((float) 0.5, getWindow());
    }

    @Override
    public void takeSuccess(TResult result) {
        super.takeSuccess(result);
        uploadImage(result.getImages());
    }

    @Override
    public void takeFail(TResult result, String msg) {
        super.takeFail(result, msg);
    }


    private void uploadImage(ArrayList<TImage> images) {
        try {
            String photoPath = images.get(0).getCompressPath();
            if (TextUtils.isEmpty(photoPath))
                photoPath = images.get(0).getOriginalPath();
            if (photoType == 1) {
                objectReverseKey = "temp/" + System.currentTimeMillis() + ".jpg";
                OssUtils.uploadPic(photoPath, objectReverseKey, new OSSCompletedCallback<PutObjectRequest, PutObjectResult>() {
                    @Override
                    public void onSuccess(PutObjectRequest putObjectRequest, PutObjectResult putObjectResult) {
                        isImageUploading = false;
                    }

                    @Override
                    public void onFailure(PutObjectRequest putObjectRequest, ClientException e, ServiceException e1) {
                        isImageUploading = false;
                        objectReverseKey = "";
                        ToastUtils.showToast("图片上传失败！请稍后再试");
                    }
                }, new OssUtils.onPhotoUploadResult() {
                    @Override
                    public void onResult(String key, String filePath) {

                    }

                    @Override
                    public void onProgress(long currentSize, long totalSize) {
                        if (currentSize >= totalSize) {
                            isImageUploading = false;
                        } else {
                            isImageUploading = true;
                        }
                    }
                });
                Glide.with(RegisterThirdStepActivity.this).load(photoPath).skipMemoryCache(true).error(R.drawable.register_icon_head_default).into(registerNegImg);


            } else if (photoType == 2) {
                objectHandKey = "temp/" + System.currentTimeMillis() + ".jpg";
                OssUtils.uploadPic(photoPath, objectHandKey, new OSSCompletedCallback<PutObjectRequest, PutObjectResult>() {
                    @Override
                    public void onSuccess(PutObjectRequest putObjectRequest, PutObjectResult putObjectResult) {
                        isImageUploading = false;
                    }

                    @Override
                    public void onFailure(PutObjectRequest putObjectRequest, ClientException e, ServiceException e1) {
                        isImageUploading = false;
                        objectHandKey = "";
                        ToastUtils.showToast("图片上传失败！请稍后再试");
                    }
                }, new OssUtils.onPhotoUploadResult() {
                    @Override
                    public void onResult(String key, String filePath) {

                    }

                    @Override
                    public void onProgress(long currentSize, long totalSize) {
                        if (currentSize >= totalSize) {
                            isImageUploading = false;
                        } else {
                            isImageUploading = true;
                        }
                    }
                });
                Glide.with(RegisterThirdStepActivity.this).load(photoPath).skipMemoryCache(true).error(R.drawable.register_icon_head_default).into(registerHandImg);
            } else {
                objectFrontKey = "temp/" + System.currentTimeMillis() + ".jpg";
                OssUtils.uploadPic(photoPath, objectFrontKey, new OSSCompletedCallback<PutObjectRequest, PutObjectResult>() {
                    @Override
                    public void onSuccess(PutObjectRequest putObjectRequest, PutObjectResult putObjectResult) {
                        isImageUploading = false;
                    }

                    @Override
                    public void onFailure(PutObjectRequest putObjectRequest, ClientException e, ServiceException e1) {
                        isImageUploading = false;
                        objectFrontKey = "";
                        ToastUtils.showToast("图片上传失败！请稍后再试");
                    }
                }, new OssUtils.onPhotoUploadResult() {
                    @Override
                    public void onResult(String key, String filePath) {

                    }

                    @Override
                    public void onProgress(long currentSize, long totalSize) {
                        if (currentSize >= totalSize) {
                            isImageUploading = false;
                        } else {
                            isImageUploading = true;
                        }
                    }
                });
                Glide.with(RegisterThirdStepActivity.this).load(photoPath).skipMemoryCache(true).error(R.drawable.register_icon_head_default).into(registerPosImg);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private void showCropImage(Intent data, ImageView imageView) {

        try {
            String path = imageStore.getPath();
            Bitmap compressPhoto = CompressPhoto.compressBySize(path, 800, 800);

            if (compressPhoto != null) {
                CompressPhoto.saveFile(compressPhoto, path);
            }

            if (photoType == 0) {
                objectFrontKey = "temp/" + System.currentTimeMillis() + ".jpg";
                OssUtils.uploadPic(path, objectFrontKey, new OSSCompletedCallback<PutObjectRequest, PutObjectResult>() {
                    @Override
                    public void onSuccess(PutObjectRequest putObjectRequest, PutObjectResult putObjectResult) {
                        isImageUploading = false;
                    }

                    @Override
                    public void onFailure(PutObjectRequest putObjectRequest, ClientException e, ServiceException e1) {
                        isImageUploading = false;
                        objectFrontKey = "";
                        ToastUtils.showToast("图片上传失败！请稍后再试");
                    }
                }, new OssUtils.onPhotoUploadResult() {
                    @Override
                    public void onResult(String key, String filePath) {

                    }

                    @Override
                    public void onProgress(long currentSize, long totalSize) {
                        if (currentSize >= totalSize) {
                            isImageUploading = false;
                        } else {
                            isImageUploading = true;
                        }
                    }
                });

            } else if (photoType == 1) {
                objectReverseKey = "temp/" + System.currentTimeMillis() + ".jpg";
                OssUtils.uploadPic(path, objectReverseKey, new OSSCompletedCallback<PutObjectRequest, PutObjectResult>() {
                    @Override
                    public void onSuccess(PutObjectRequest putObjectRequest, PutObjectResult putObjectResult) {
                        isImageUploading = false;
                    }

                    @Override
                    public void onFailure(PutObjectRequest putObjectRequest, ClientException e, ServiceException e1) {
                        isImageUploading = false;
                        objectReverseKey = "";
                        ToastUtils.showToast("图片上传失败！请稍后再试");
                    }
                }, new OssUtils.onPhotoUploadResult() {
                    @Override
                    public void onResult(String key, String filePath) {

                    }

                    @Override
                    public void onProgress(long currentSize, long totalSize) {
                        if (currentSize >= totalSize) {
                            isImageUploading = false;
                        } else {
                            isImageUploading = true;
                        }
                    }
                });
            } else if (photoType == 2) {
                objectHandKey = "temp/" + System.currentTimeMillis() + ".jpg";
                OssUtils.uploadPic(path, objectHandKey, new OSSCompletedCallback<PutObjectRequest, PutObjectResult>() {
                    @Override
                    public void onSuccess(PutObjectRequest putObjectRequest, PutObjectResult putObjectResult) {
                        isImageUploading = false;
                    }

                    @Override
                    public void onFailure(PutObjectRequest putObjectRequest, ClientException e, ServiceException e1) {
                        isImageUploading = false;
                        objectHandKey = "";
                        ToastUtils.showToast("图片上传失败！请稍后再试");
                    }
                }, new OssUtils.onPhotoUploadResult() {
                    @Override
                    public void onResult(String key, String filePath) {

                    }

                    @Override
                    public void onProgress(long currentSize, long totalSize) {
                        if (currentSize >= totalSize) {
                            isImageUploading = false;
                        } else {
                            isImageUploading = true;
                        }
                    }
                });
            }
            Glide.with(this).load(path).into(imageView);

        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}
